using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Wrath.Xml.Objects;
using Wrath.Xml.Objects.Controls;

namespace Wrath.RuleForge.Windowing
{
    public partial class GenericControlComponent : WindowControlComponent
    {
        private GenericControl genericControl;

        public GenericControl GenericControl
        {
            get { return genericControl; }
            set { genericControl = value; }
        }

        public GenericControlComponent()
        {
            InitializeComponent();
        }

        public GenericControlComponent(GenericControl definition, List<WindowControl> controls)
            : base(definition, controls)
        {
            InitializeComponent();

            genericControl = definition;
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            // Calling the base class OnPaint
            base.OnPaint(pe);

            string text = ((genericControl.Name != null) ? genericControl.Name : "<no name>");
            Font nameFont = new Font(FontFamily.GenericSansSerif, 8.0f);


            //if (DesignMode)
            //{
                text += " {" + this.GetType().Name + "}";
            //}

            SizeF stringSize = pe.Graphics.MeasureString(text, nameFont);

            pe.Graphics.DrawString(text, nameFont, Brushes.Black,
                new PointF((this.Width / 2) - (stringSize.Width / 2), (this.Height / 2) - (stringSize.Height / 2)));
        }
    }
}
